﻿@model TraCuuThuatNgu.ViewModels.AddTermViewModel
@{
    ViewBag.Title = "Chỉnh sửa thuật ngữ";
    Layout = "~/Views/Shared/_Admin.cshtml";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<style type="text/css">
    #ManageEntries
    {
        border-color: #143D6B;
        background: url("/Content/img/backgrounds/menu-item-active.jpg") left top repeat-x;
    }
</style>
<div class="row-fluid">
    <a href="/ManageEntries" class="btn-link">
        <h4 style="margin-top: 0px">
            ← Quay lại danh sách</h4>
    </a>
    <div class="span span12">
        <div class="head">
            <div class="icm-edit">
            </div>
            <h1>
                Chỉnh sửa thuật ngữ</h1>
            <div class="clear">
            </div>
        </div>
        <div class="block">
            @using (Html.BeginForm("Edit", "ManageEntries", FormMethod.Post, new { id = "edit-synset-form" }))
            {
                <input type="hidden" value='@Request.QueryString["synsetId"]' name="synsetId" />
                <div class="entry-form">
                    <div class="editor">
                        <div class="editor-label">
                            Thuật ngữ
                        </div>
                        <div class="editor-field">
                            @Html.TextBoxFor(m => m.HeadWord, new { disabled = "disabled" })
                            @Html.HiddenFor(m => m.HeadWord)
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="editor">
                        <div class="editor-label">
                            Loại từ
                        </div>
                        <div class="editor-field">
                            @Html.DropDownListFor(m => m.Catagory, new[] {
new SelectListItem() {Text = "Danh từ", Value = "n",Selected = true},
new SelectListItem() {Text = "Động từ", Value = "v"},
new SelectListItem() {Text = "Tính từ", Value = "a"}
})
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="editor">
                        <div class="editor-label">
                            Giải thích
                        </div>
                        <div class="editor-field">
                            @Html.TextAreaFor(m => m.Def, new { Class = "text" })
                            @Html.ValidationMessageFor(m => m.Def)
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="editor">
                        <div class="editor-label">
                            Ví dụ
                        </div>
                        <div class="editor-field">
                            @Html.TextAreaFor(m => m.Exa, new { Class = "text" })
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="editor">
                        <div class="editor-label">
                            Từ đồng nghĩa
                        </div>
                        <div class="editor-field">
                            <input type="text" id="input-synonym" />
                            @Html.HiddenFor(m => m.Synonyms, new { id = "synonyms-data" })
                            <a style="padding: 5px 26px; margin-left: 5px;" href="javascript://" id="add-synonym"
                                class="btn-link btn-add">Thêm từ đồng nghĩa</a>
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="editor">
                        <div class="editor-label">
                        </div>
                        <div class="editor-field">
                            <ul id="list-synonyms">
                                @foreach (var item in ViewBag.ListSynonyms)
                                {                                                                          
                                    <li><span class='label label-success'><span>@item</span> <a title='xóa' class='delete-synonym'
                                        href='javascript:'>x</a></span></li>                             
                                }
                            </ul>
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="editor">
                        <div class="editor-label">
                        </div>
                        <div class="editor-field">
                            <input type="submit" class="btn" value="Cập nhật" />
                            @if (Request.QueryString["r"] != null)
                            { 
                                <span style="color:green">Cập nhật thành công!</span>
                            }
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                </div>   
            }
            <h3 style="margin-left: 10px; color: #f89406">
                Các nghĩa khác của thuật ngữ</h3>                
                <a style="padding: 5px 26px; margin:0px 8px;" href="/ManageEntries/Add?headWord=@Model.HeadWord" id="add-synonym"
                                class="btn-link btn-add">Thêm nghĩa mới</a>
            <table cellpadding="0" cellspacing="0" width="100%" class="table">
                <thead>
                    <tr>
                        <th width="5%">
                            STT
                        </th>
                        <th width="7%">
                            Loại từ
                        </th>
                        <th width="40%">
                            Giải thích
                        </th>
                        <th width="18%">
                            Từ đồng nghĩa
                        </th>
                        <th width="20%">
                            Ví dụ
                        </th>
                        <th width="10%">
                            <center>
                                Thao tác</center>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @{
                        var count = 1;                        
                    }
                    @foreach (var item in ViewBag.ListAnotherSynset)
                    {                        
                        <tr>
                            <td>
                                @count
                            </td>
                            <td>
                                @if (item.Category.Equals("n"))
                                { <span>Danh từ</span> }
                                else if (item.Category.Equals("v"))
                                { <span>Động từ</span> }
                                else
                                { <span>Tính từ</span> }
                            </td>
                            <td>
                                @item.Def
                            </td>
                            <td>
                                @foreach (var str in item.WordIndexes)
                                {
                                    if (!str.HeadWord.Equals(Model.HeadWord))
                                    {                                        
                                    <span class="synset-item">@str.HeadWord</span>                                    
                                    }
                                }
                                <script>                                    $("span").last().removeClass('synset-item');</script>
                            </td>
                            <td>
                                @item.Exa
                            </td>
                            <td align="center">
                                <a style="margin-right:5px" class="btn-edit" title="Sửa" href="/ManageEntries/Edit?synsetId=@item.SynsetId&headWord=@Model.HeadWord">
                                </a><a class="btn-delete synset-delete" data-index="@Model.HeadWord" data-synset="@item.SynsetId" href="javascript:" title="Xóa">
                                    
                                </a>
                            </td>
                        </tr>                          
                                count++;
                    }
                </tbody>
            </table>
        </div>
    </div>
    <div class="clear">
    </div>
</div>
